package com.baidu.eureka.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author caixiaofeng
 * @version 1.0
 * @Description: << mybatisPlus配置类>>
 * @company 浙江优创信息技术有限公司
 * @create 2020-07-18 13:07
 */
//启动事务
@EnableTransactionManagement
@Configuration
//扫描dao层
@MapperScan("com.baidu.eureka.dao")
public class MybatisPlusConfig {

    /**
     * 分页拦截器bean
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
        return paginationInterceptor;
    }
}
